<script setup lang="ts">
import { getHomeBannerAPI, getHomeCategoryAPI, getHomepanelAPI } from '@/services/home';
import { onLoad, type onShow } from '@dcloudio/uni-app';
import CustomNavbar from './components/CustomNavbar.vue';
import CategoryPanel from './components/CategoryPanel.vue';
import HotPanel from './components/HotPanel.vue';
import { reactive } from 'vue';
import type { BannerItem } from '@/types/home';
const state = reactive({
  bannerList: [] as BannerItem[],
  categoryList: [],
  homePanelList: []
})
onLoad(() => {
  getBannerList()
  getCategoryList()
  getHomePanelList()
})
// 轮播图
const getBannerList = async () => {
  const res = await getHomeBannerAPI()
  state.bannerList = res.result

}
// 获取首页前台分类
const getCategoryList = async () => {
  const res = await getHomeCategoryAPI()
  state.categoryList = res.result

}
// 热门推荐
const getHomePanelList = async () => {
  const res = await getHomepanelAPI()
  state.homePanelList = res.result

}
</script>

<template>
  <CustomNavbar />
  <XtxSwiper :list="state.bannerList" />
  <CategoryPanel :list="state.categoryList" />
  <HotPanel :list="state.homePanelList" />
  <view class="index">

  </view>
</template>

<style lang="scss"></style>
